<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>


    <script>

        
        // post请求
        //   在send中携带数据  aa=小花&bb=666

        const xhr = new XMLHttpRequest() ;
        xhr.open('post' , '../php/04post.php' , true) ;
        // post请求必须设置请求头
        xhr.setRequestHeader('content-type','application/x-www-form-urlencoded') ;
        // 通过send携带数据
        xhr.send('user=小花&pwd=666') ;
        xhr.onreadystatechange = function() {
            if(xhr.readyState === 4 && xhr.status === 200) {
                let data = xhr.responseText ;
                console.log(data);
            }
        }





    </script>
    
</body>
</html>